<!--{include file="header.html"}-->
<!-- END HEAD -->

<!-- BEGIN BODY -->
<body class="page-header-fixed">
<!-- BEGIN HEADER -->
<!--{include file="top.html"}-->
<!-- END HEADER -->

<!-- BEGIN CONTAINER -->
<div class="page-container row-fluid">
<!-- 左边开始 -->
<div class="page-sidebar nav-collapse collapse">
<!-- BEGIN SIDEBAR MENU -->
<!--{include file="menu.html"}-->
<!-- END SIDEBAR MENU -->
</div>
<!-- 左边结束 -->

<!-- BEGIN PAGE -->
<div class="page-content">
<!-- 右边开始-->
<div class="container-fluid" >
<!--右边标题导航开始-->
<div class="row-fluid">
<div class="span12">
<!-- BEGIN PAGE TITLE & BREADCRUMB-->
<!--{include file="nav.html"}-->
<!-- END PAGE TITLE & BREADCRUMB-->
</div>
<!--右边标题导航结束-->

<!--右边中介内容开始-->
<div class="content" >
<p class="fl"></p>
<div class="portlet box grey">
<!--标题-->
<div class="portlet-title">
<div class="caption"><i class="icon-reorder"></i>资源库</div>
</div>

<!--表格内容-->
<div class="search_resources">
<input id="search" type="text" placeholder="输入后请按回车搜索" value="<!--{if $key}--><!--{$key}--><!--{/if}-->" />
<!--{if $key}-->
<span id="close">X</span>
<!--{/if}-->
<a class="hot-keyword" href="?search=KTV">KTV</a>
<a class="hot-keyword" href="?search=吃喝">吃喝</a>
<a class="hot-keyword" href="?search=唱歌">唱歌</a>
<a class="hot-keyword" href="?search=超市">超市</a>
<a class="hot-keyword" href="?search=洗浴">洗浴</a>
</div>

<!--中间内容开始-->
<table cellpadding="0" cellspacing="0" class="resources-table">
<tbody>
<tr>
<td>名称</td><td>数量</td><td>价格</td><td>地址</td>
<td>截止时间</td><td>操作</td>
</tr>
<!--{foreach from = $resources item = value key = k}-->
<tr <!--{if $k % 2 != 0}-->class="gray"<!--{/if}--> >
<td><a href="javascript: void(0);" class="resources-link"><!--{$value.resource_title}--></a></td>
<td><!--{$value.num}--></td>
<td><!--{if $value.price == '0.00'}-->免费<!--{else}-->￥<!--{$value.price}--><!--{/if}--></td>
<td><!--{$value.addr}--></td>
<td><!--{if $value.deadline}-->
<!--{date('Y-m-d', substr($value.deadline, 0, 10))}-->
<!--{else}-->长期有效<!--{/if}--></td>
<td><a class="label-detail" rel="<!--{$value.id_resource}-->" >详情</a></td>
</tr>
<!--{/foreach}-->
</tbody>
</table>

<!--Page-->
<div class="portlet-body fuelux">  
<div class="content event_list clearfix">
<div class="handle_paging clearfix">
<!--{if $page_html}-->
<div class="pagination fr">
<ul>
<!--{$page_html}-->
</ul>
</div>
<!--{/if}-->
</div>
</div>
<!--中间内容结束-->
</div>
</div>
</div>
<!--右边中介内容结束-->
</div>
<!-- 右边结束-->
</div>
<!-- END PAGE -->
</div>

<!--资源库详情弹窗-->
<div id="prompt" style="width:800px;top:20%;display: none;"></div>
<div id="pop_up" style="display: none;"></div>
<!-- END CONTAINER -->

<!-- BEGIN FOOTER -->
<!--{include file="footer.html"}-->
<!-- END PAGE LEVEL SCRIPTS -->
<script>

$(function() {
  $("#search").keypress(function(e) {
    if(e.which == 13) { //执行搜索
      $(this).blur();
    }
  }).blur(function () {
    if($(this).val()) {
      window.location.href = '?search=' + $(this).val();
    }
  });
  
  $('#close').click(function () {
    window.location.href = '?';
  });
  
  $('.label-detail').click(function () {
    $.post('<!--{$url_prefix}-->resources/resource_info', {
      'id': $(this).attr('rel'),
    }, function(result) {
      if(result !== 0 || result !== false) {
        $('#prompt').html(result).show();
        $("#pop_up").show();
      }
    });
  });
});

var closeTips = function () {
  $("#prompt").hide();
  $("#pop_up").hide();
}
var resource_list_page = function(offset) {
  if(getUrlParam('search') )
    if( ! getUrlParam('offset'))
      window.location.href = window.location.href + '&offset=' + offset;
    else 
      window.location.href = replaceParamVal('offset', offset);
  else
    window.location.href = '?offset=' + offset;
}

//获取URL参数
var getUrlParam = function(name) {
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  var r = window.location.search.substr(1).match(reg);
  if (r != null) 
    return unescape(r[2]); 
  return null;
}

//更换参数值
var replaceParamVal = function (paramName, replaceWith) {
  var oUrl = this.location.href.toString();
  var re   = eval('/(' + paramName + '=)([^&]*)/gi');
  var nUrl = oUrl.replace(re,paramName + '=' + replaceWith);
  return nUrl;
}

</script>

</body>
</html>